package mySeleniumDriver;

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;



public class SeleniumDriver extends BaseClass {
  @Parameters({"automationName", "platformName", "platformVersion", "browserName",
      "browserVersion", "deviceName", "appPackage", "appActivity"})
  @BeforeTest(alwaysRun = true)
  public void startSetup(String automationName, String platformName, String platformVersion,
      String browserName, String browserVersion, String deviceName, String appPackage,
      String appActivity) throws Exception {
    try {
      automationEnvironment = automationName;
      EnvironmentSetup esObj = new EnvironmentSetup();
      esObj.setup(automationName, platformName, platformVersion, browserName, browserVersion,
          deviceName, appPackage, appActivity);
    } catch (Exception e) {
      setUpSuccess = false;
      log("error",
          "Exception caught in StartSetUp function. Aborting the operation." + e.getMessage());
    }
  }

  @Test
  public void startExecution() throws Exception {
    if (setUpSuccess) {
      UtilityFile ufObj = new UtilityFile();
      ufObj.ReadUtilFile();
    }
  }


  @AfterTest
  public void cleanUpAfterExecution() throws Exception {
    if (setUpSuccess) {
      CloseFunction cfObj = new CloseFunction();
      cfObj.close();
    }
  }

}
